import request from "@/utils/request";

// 查询AD组列表
export const groupList = query => {
  return request({
    url: "/azure/group/list",
    method: "get",
    params: query
  });
};

// group
export const group = id => {
  return request({
    url: "/azure/group/get/" + id,
    method: "get"
  });
};

// 添加组
export const addGroup = data => {
  return request({
    url: "/azure/group/add",
    method: "post",
    data: data
  });
};

// members
export const members = query => {
  return request({
    url: `/azure/group/${query.groupId}/members`,
    method: "get",
    params: query
  });
};

export const departmentTree = query => {
  return request({
    url: `/azure/group/departmentTree`,
    method: "get",
    params: query
  });
};

export const deleteGroup = id => {
  return request({
    url: `/azure/group/delete/${id}`,
    method: "delete"
  });
};

export const subscribedSkuDataSource = () => {
  return request({
    url: `/azure/group/subscribedSkuList`,
    method: "get"
  });
};

export const licenses = id => {
  return request({
    url: `/azure/group/${id}/licenses`,
    method: "get"
  });
};

export const assignLicenses = (id, data) => {
  return request({
    url: `/azure/group/${id}/licenses/assign`,
    method: "post",
    data: data
  });
};

export const groupSetting = id => {
  return request({
    url: `/azure/group/${id}/setting`,
    method: "get"
  });
};
export const saveSetting = data => {
  return request({
    url: `/azure/group/saveSetting`,
    method: "post",
    data
  });
};

export default {
  group,
  groupList,
  members,
  departmentTree,
  addGroup,
  deleteGroup,
  licenses,
  subscribedSkuDataSource,
  assignLicenses,
  groupSetting,
  saveSetting
};
